#include "check.h"
#include "ui_check.h"
#include<QPainter>
#include<QPushButton>
#include<QIcon>
#include"widget.h"
#include"play.h"
#include<QFile>
#include<QDir>
#include<QLabel>
#include<QDebug>
check::check(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::check)
{
    ui->setupUi(this);
    QPushButton* back=new QPushButton(this);
    //back->setFixedSize(66,66);
    back->move(700,500);
    back->setIcon(QIcon(":/res/back.png"));
    //back->setStyleSheet("QPushButton {border: 0 px  ; }");
    connect(back,&QPushButton::clicked,this,[=](){
        Widget * hall=new Widget;
        hall->show();
        this->close();
    });

    connect(ui->easy,&QPushButton::clicked,this,[=](){
        play *play_window=new play;
        play_window->show();
        this->close();
        speed=500;
    });
    connect(ui->normal,&QPushButton::clicked,this,[=](){
        play *play_window=new play;
        speed=400;
        play_window->show();
        this->close();

    });
    connect(ui->hard,&QPushButton::clicked,this,[=](){
        play *play_window=new play;
        speed=300;
        play_window->show();
        this->close();

    });
    connect(ui->history,&QPushButton::clicked,this,[=](){
        qDebug()<<"hhh";
        QString path=QDir::currentPath();
        QFile read_data(path+"/"+"data.txt");
        read_data.open(QIODevice::ReadOnly);
        QString data=read_data.readLine();
        data+="分";
        QWidget *data_show=new QWidget;
        data_show->setGeometry(500,500,300,300);
        data_show->setWindowIcon(QIcon(":/res/ico.png"));
        data_show->setWindowTitle("历史数据");
        QLabel *lable=new QLabel(data_show);
        lable->setGeometry(0,0,300,100);
        //qDebug()<<data;

        lable->setText(data);
        QFont font("微软雅黑",26);
        lable->setFont(font);

        data_show->show();
    });
}

check::~check()
{
    delete ui;
}

void check::paintEvent(QPaintEvent *event)
{
    QPainter painter(this);
    QPixmap back_ground(":/res/game_select.png");
    painter.drawPixmap(0,0,800,600,back_ground);
}

int check::get_speed()
{
    return speed;
}
